package itesm.mx;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

public class MapsQuizActivity extends QuizActivity {
	protected int[] maps = {
		R.drawable.argentina_map,
		R.drawable.bolivia_map,
		R.drawable.brazil_map,
		R.drawable.canada_map,
		R.drawable.chile_map,
		R.drawable.colombia_map,
		R.drawable.costa_rica_map,
		R.drawable.cuba_map,
		R.drawable.dominican_republic_map,
		R.drawable.ecuador_map,
		R.drawable.haiti_map,
		R.drawable.honduras_map,
		R.drawable.mexico_map,
		R.drawable.nicaragua_map,
		R.drawable.panama_map,
		R.drawable.paraguay_map,
		R.drawable.peru_map,
		R.drawable.united_states_map,
		R.drawable.uruguay_map
	};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.imagequiz);
		countries = getResources().getStringArray(R.array.maps_countries);
		
		nextQuestion();
		displayQuestion();
	}
	
	protected void displayQuestion() {
		ImageView[] answerButtons = {
			(ImageView) findViewById(R.id.answer1),
			(ImageView) findViewById(R.id.answer2),
			(ImageView) findViewById(R.id.answer3),
			(ImageView) findViewById(R.id.answer4)
		};
		
		for (int i = 0; i < answerButtons.length; i++) {
			answerButtons[i].setImageResource(maps[currentQuestion[i]]);
			answerButtons[i].setOnClickListener(this);
		}
		
		String questionText = getResources().getString(R.string.maps_question);
		questionText += " ";
		questionText += countries[currentAnswer];
		questionText += getResources().getString(R.string.question_terminator);
		
		TextView question = (TextView) findViewById(R.id.question);
		question.setText(questionText);
	}
	
	@Override
	protected void onFinish(int score) {
		updateStats(AndroidProject.QUIZ_MAPS, score);
	}
	protected int getId(){return 1;}
}
